<template>
  <div id="course">
    <c-title :hide="false" text="会员升级"></c-title>
    <div class="member">
      <div class="header-avatar">
        <img :src="member_info.avatar" alt="">
      </div>
      <div class="user-info">
        <div class="user-name-box">{{ member_info.nickname }}</div>
        <div class="user-level">{{ member_info.level_name }}</div>
      </div>
    </div>
    <div class="content" >
      <div class="content-top-box">
        <div class="center" style="height: 0.9375rem;line-height: 0.9375rem;">
          <div style="font-size: 0.9375rem;font-weight: 400;">会员尊享特权</div>
          <div class="tips">（{{level_name}}可免费观看）</div>
        </div>
        <div class="top">
          <div class="left">
            <img :src="course_goods.goods_thumb">
          </div>
          <div class="right">
            <div class="title">
              <div class="fz-30 text-overflow">{{course_goods.goods_title}}</div>
            </div>
            <div class="right-box">
              <div class="teacher">
                <img  class="teacher-img" :src="course_goods.lecturer_avatar" alt="" />
                <span>{{course_goods.lecturer_name}}</span>
              </div>
              <div class="num">共{{course_goods.course_chapter_num}}节</div>
            </div>
            <div class="right-price">
              <span class="free">{{ $i18n.t('money') }}0.00</span>
              <span style="color:#999;font-size: 0.75rem;text-decoration: line-through;">{{$i18n.t('money')}}{{ price }}</span>
            </div>
          </div>
        </div>
      </div>

      <div class="bottom">
          <template v-if="level_type==2">
            <div class="levle-type-2">
             <div class="center" style="padding: 0.75rem;border-bottom: 1px solid #F7F8FB;">
              <div style="font-size: 0.9375rem;color:#333">会员套餐</div>
              <div class="tips">（购买指定商品成为会员）</div>
             </div>
             <div style="padding:0 0.75rem .75rem">
              <div class="good-wrap" v-for="(item,index) in level_data" :key="index">
                  <div class="good-tit">{{item.level_name}}</div>
                  <div class="good" v-for="(list,index) in item.goods" :key="index">
                    <div class="img">
                      <img :src="list.thumb">
                    </div>
                    <div class="bt">
                        <div class="head">{{list.title}}</div>
                        <div class="center" style="justify-content: space-between;align-items: baseline;">
                          <div class="cash">
                            <span style="font-size: 0.6875rem;margin-right: 0.3125rem;">{{$i18n.t('money')}}</span>
                            <span style="font-size: 1.125rem;">{{list.price}}</span>
                          </div>
                          <button  @click="gotoBuy(list.id)">立即购买</button>
                        </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </template>
          <!-- 余额充值 -->
          <template v-if="level_type!=2">
            <div class="level-type">
              <div style="font-size: 0.9375rem;color:#333;height: 0.9375rem;line-height: 0.9375rem;">会员套餐</div>
              <div class="wrap">
                  <div class="item" v-for="(item,index) in level_data" :key="index" @click="choose(index)" :class="{current:current_index==index}">
                    <template  v-if="level_type!=4">
                      <div class="card" >
                        <div class="level">{{item.level_name}}</div>
                        <div class="amount">
                          <span class="num" v-if="level_type==0">{{item.order_money}}元</span>
                          <span class="num" v-if="level_type==1">{{item.order_count}}个</span>
                          <span class="num" v-if="level_type==3">{{item.team_performance}}元</span>
                        </div>
                        <div class="al">
                          <span v-if="level_type==0||level_type==1">订单</span>
                          <span  v-if="level_type==3">团队</span><span v-if="level_type==1">数量</span>
                          <span v-if="level_type==0">金额</span><span v-if="level_type==3">业绩</span>
                          <span>满</span>
                        </div>
                      </div>
                      <div class="yel">
                        <div class="first">
                          <span v-if="level_type==0">订单金额</span>
                          <span v-if="level_type==1">订单数量</span>
                          <span v-if="level_type==3">团队业绩</span>还差
                        </div>
                        <div class="second">
                            <span  v-if="level_type==0">{{item.member_order_money.toFixed(2)}}元</span>
                            <span  v-if="level_type==1">{{item.member_order_count}}个</span>
                            <span  v-if="level_type==3">{{item.member_team_performance.toFixed(2)}}元</span>
                        </div>
                      </div>
                    </template>
                    <div v-else class="level-4">
                        <div>
                          <div class="level">{{item.level_name}}</div>
                          <div class="balance-recharge">{{ item.balance_recharge }}元</div>
                        </div>
                        <div class="btn-recharge" :class="current_index==index?'heigh-light':''" @click.stop="toRecharge(item.balance_recharge)"> 立即充值 </div>
                    </div>
                  </div>
              </div>
            </div>
            <div  v-if="level_data.length > 0 && Number(level_type)!==4"  :class="fun.getPhoneEnv() == 3 ? 'pcStyle' : 'bottom-buy'">
              <div class="toBuy" @click="goto" >立即购买</div>
            </div>
            <yz-blank v-else :datas="level_data" text="什么也没有"></yz-blank>
          </template>
      </div>
    </div>
  </div>
</template>

<script>
import course_member_level_controller from "./course_member_level_controller";
export default course_member_level_controller;
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" rel="stylesheet/scss" scoped>
::v-deep  .van-nav-bar__left .van-button--default{
  background-color: #FE5E56;
}
::v-deep .van-nav-bar .van-icon{
  color:#fff;
  font-weight: bold;
  font-size: 1.125rem;
}
::v-deep .van-nav-bar{
  background-color: #FE5E56;
  border-bottom: 1px solid #FE5E56;
}
::v-deep  .van-nav-bar__title{
  color: #fff;
  font-weight: 400;
  font-size: 1.125rem;
}
#course {
  padding-bottom: 0.75rem;
  .text-overflow{
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .levle-type-2{
    background: #fff;
    border-radius: 0.625rem;
    overflow: hidden;

  }
  .level-4{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    background: #F6FAFD;
    padding-bottom: 0.75rem;
    .balance-recharge{
      margin-top: 0.9375rem;
      font-size: 1.125rem;
      color: #F15353;
    }
  }
  .card{
    background: #F6FAFD;border-top-left-radius: 0.3125rem;border-top-right-radius: 0.3125rem;
  }
  .current{
    border:1px solid #FE5E56 !important;
    .level-4{
      background-color: #fff !important;
    }
    .card{
      background-color: #fff !important;
    }
    .yel{
      background-color:#F15353;
    }
    .first{
      color: #fff !important;
    }
    .second{
      color: #fff !important;
    }
  }

  .free{
    font-size: 1.125rem;color:#F15353;margin-right: 0.5rem;font-weight: 500;
  }
  .right-price{
    flex:1;
    margin-top: 0.4688rem;
    display: flex;
    align-items: flex-end;
  }
  .user-info{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-left: 0.4063rem;
  }
  .user-name-box{
    font-size: 1rem;
    color: #FFFFFF;
    font-weight: bold;
    text-align: left;
  }
  .user-level{
    min-width: 4rem;
    background: #fff;
    border-radius: 0.625rem;
    height: 1.25rem;
    line-height: 1.25rem;
    text-align: center;
    font-size: 0.6875rem;
    padding: 0 0.5rem;
    color: #FE5E56;
  }
  .header-avatar{
    width: 3.4375rem;
    height: 3.4375rem;
    border-radius: 100px;
    overflow: hidden;
    img{
      width: 100%;
      height: 100%;
    }
  }
  .member{
    padding: 1.5rem  0.9375rem 0.75rem;
    background-color: #FE5E56;
    display: flex;
  }
  .tips{
    font-size: 0.75rem;
    color: #999;
    flex:1;
    white-space: nowrap;
    overflow-x: scroll;
    text-align: left;
  }
  .tips::-webkit-scrollbar{
    display: none;
  }
  .tit {
    font-size: 0.875rem;
    color: #333;
    margin-right: 0.4688rem;
    flex-shrink: 0;
  }
  .content-top-box{
    padding: 0.875rem 0.75rem 0.75rem;
    background: #fff;
    border-radius: 0.625rem;
    margin-bottom: 0.625rem;
    margin-top: 0.625rem;
  }
  .center{
    display: flex;
    align-items: center;
  }
  .content {
    padding: 0 0.75rem;
    .fz-30{
      font-size: 0.9375rem;
    }
    .top {
      margin-top: 0.75rem;
      display: flex;
      .left {
        display: flex;
        width: 6.3125rem;
        height: 6.3125rem;
        border-radius: 0.3125rem;
        box-sizing: border-box;

        img {
          border-radius: 0.3125rem;
          width: 100%;
          height: 100%;
        }
      }

      .right {
        display: flex;
        flex: 1;
        margin-left: 0.7813rem;
        flex-direction: column;
        .right-box{
          position: relative;
          display: flex;
          justify-content: space-between;
          align-items: center;
          color: #4B6AA7;
          font-size: 0.75rem;
          margin-top: 0.5rem;
          padding: 0.125rem 0.75rem .125rem 0.375rem;
          z-index: 2;
        }
        .right-box::after{
          position: absolute;
          content:"";
          left: 0;
          right: 0;
          top: 0;
          bottom: 0;
          background: rgba(75,106,167,0.05);
          // opacity: .05;
          border-radius: 0.125rem;
          z-index: 1;
        }
        .title {
          color: #000;
          font-size: 14px;
          text-align: left;
        }

        .teacher {
          display: flex;
          align-items: center;
        }
        .teacher-img{
          width: 1.375rem;
          height: 1.375rem;
          border-radius: 100px;
          margin-right: 0.25rem;
        }
      }
    }
    .level-type{
      background: #fff;
      padding: 0.75rem .75rem 0;
      border-radius: 0.625rem;
      overflow: hidden;
      .num{
        font-size: 1.125rem;
      }

    }
    .seconde,.first{
      font-size: 0.75rem;
   }
    .bottom {
      text-align: left;
      .wrap {
        width: 100%;
        display: grid;
        // flex-wrap: wrap;
        grid-template-columns: repeat(3,1fr);

        .item {
          width: 6.5625rem;
          min-height: 7.0313rem;
          background-color: #fff;
          border-radius: 0.3125rem;
          overflow: hidden;
          margin: 0.75rem 2% 0.75rem 0;
          box-sizing: border-box;
          text-align: center;
          border:1px solid #F6FAFD;

          .level {
            color: #000;
            font-size: 0.875rem;
            padding-top: 0.75rem;
          }

          .al {
            margin-top: 0.5rem;
            font-size: 0.75rem;
            color:#6E6E79;
            padding-bottom: 1.0313rem;
          }

          .amount {
            margin-top: 0.6875rem;
            color: #F15353;
            font-size: 1.125rem;
          }


          .yel {
            min-height: 2.75rem;
            position: relative;
            color: #999999;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size:0.75rem;
            flex-wrap: wrap;
            z-index: 2;


          }
          .yel::after{
            position: absolute;
            content:"";
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background-color: #999;
            opacity: .1;
            z-index: 1;
            border-bottom-left-radius: 0.3125rem;
            border-bottom-right-radius: 0.3125rem;
          }
          .heigh-light{
            color:#fff !important;
            background-color:#FE5E56 !important;
          }

          .btn-recharge {
            display: inline-block;
            color: #999999;
            margin-top:1.0313rem;
            border-radius: 1.0938rem;
            font-size: 0.75rem;
            width: 4.6875rem;
            height: 1.5rem;
            line-height: 1.5rem;
            text-align: center;
            left: 1.5rem;
            background-color: #EDF1F3;
          }
        }
        .item:last-child { margin-right: 0; }
      }
      .pcStyle{
        width: 375px;
        position: fixed;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        background: #fff;
        padding: 0.2813rem 0.75rem;
      }
      .bottom-buy{
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        padding: 0.2813rem 0.75rem;
      }
      .toBuy {
        width: 100%;
        height: 2.5rem;
        line-height: 2.5rem;
        background-color: #FE5E56;
        border-radius: 1.2813rem;
        font-size: 0.9375rem;
        color: #fff;
        text-align: center;
      }

      .good-wrap {
        width: 100%;
        padding: 0.75rem;
        background: #F6FAFD;
        border-radius: 0.3125rem;
        margin-top: 0.75rem;

        .good-tit {
            font-size: 0.875rem;
            color: #000;
          }

          .good {
            display: flex;
            margin-top: 0.75rem;

            .img {
              width: 4.375rem;
              height:4.375rem;
              flex-shrink: 0;
            }
            img {
                width: 100%;
                height: 100%;
                border-radius: 0.3125rem;
              }
            .bt {
              margin-left: 0.75rem;
              display: flex;
              flex-direction: column;
              justify-content: space-between;
              flex:1;
              button{
                border:none;
                width: 4.6875rem;
                height: 1.5rem;
                color:#fff;
                font-size: 0.75rem;
                background: #FE5E56;
                border-radius: 1.0938rem;
              }

              .head {
                color: #000;
                font-size: 0.875rem;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
              }

              .cash {
                margin-top: 0.75rem;
                color: #F15353;
              }
            }
          }
      }
    }
  }
}
</style>
